Skip to content

Fixed bug #81096: Inconsistent range inferece for variables passed by reference #7121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

dstogov
Copy link
Member

@dstogov dstogov commented Jun 8, 2021

Detect references before range inference and exclude them from range inference.

@nikic
Copy link
Member

nikic commented Jun 9, 2021

I think the general approach here is okay. However, it is easy to cause discrepancies between this reference inference and type inference.

I've prepared https://gist.github.com/nikic/c0a903adace7272b64a60e9b36cf0a31 to add a consistency assertion and fix handling for a few opcodes I found this way (for PRE_INC/DEC the error was on the type inference side, I fixed that separately).

Note that currently this assertions is broken when type inference is called from tracing JIT, as the reference inference doesn't happen there. I'm not sure whether the original problem also affects the JIT inference -- do we need to perform something similar to zend_mark_cv_references there as well?

@dstogov
Copy link
Member Author

dstogov commented Jun 9, 2021

@nikic Thanks for corrections, I'll update the PR soon.

In tracing JIT we don't perform range inference. We only copy ranges inferred on function SSA.
So that ASSERTION doesn't make sense for tracing JIT. I think, it may be kept, but excluded for tracing JIT.

dstogov and others added 3 commits June 9, 2021 18:38
… reference

Detect references before range inference and exclude them from range
inference.
@dstogov
Copy link
Member Author

dstogov commented Jun 9, 2021

@nikic please take a quick look into the last commit. I hope, everything should be fine now.

@dstogov
Copy link
Member Author

dstogov commented Jun 10, 2021

Merged as 7368d0c

@dstogov dstogov closed this Jun 10, 2021
nikic added a commit that referenced this pull request Jun 10, 2021
This issue is properly fixed by GH-7121 on master. For older
branches, disable the use of range information in SCCP, to
reduce impact of potentially incorrect ranges.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants